﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace EternitySolver.Core.Solvers.FixedPath
{
    public class RandomSolver : FixedPathSolver
    {
        public override LinkedList<int> GetPath(Board board)
        {
            var items = new List<int>(board.PlacedTiles.Count);
            for (var i = 0; i < board.PlacedTiles.Count; i++)
            {
                items.Add(i);
            }
            var random = new List<int>(items.OrderBy(p => Guid.NewGuid().ToString()));
            var path = new LinkedList<int>();
            var node = path.AddFirst(random[0]);
            for (var i = 1; i < random.Count; i++)
            {
                node = path.AddAfter(node, random[i]);
            }
            return path;
        }
        public override string ToString()
        {
            return "Random Solver";
        }
    }
}